<template>
  <div class="detail-page">
    <div class="header"><i class="icon iconfont iconbtn_nav_back" @click-left="$router.back()"></i></div>
    <div class="item">
    <div class="content">
        <div class="title">{{item.title}}</div>
        <div class="info">
            <div class="time">{{timeChange(item.created_at)}}</div>
            <div class="see">
                <van-icon name="eye-o" class="eye" />
                <span>{{item.read}}</span>
            </div>
            <div class="zan">
                <van-icon name="good-job-o" class="eye"/>
                <span>{{item.star}}</span>
            </div>
        </div>
    </div>
  </div>
    <div v-html="item.content" class="type-area"></div>
  </div>
</template>

<script>
import { detailAPI } from '@/api/index'
export default {
  data () {
    return {
      item: {}
    }
  },
  async created () {
    const res = await detailAPI(this.$route.params.id)
    console.log(res)
    this.item = res.data
  },
  methods: {
    timeChange (data) {
      let time = data // 将需要格式化的数据传入
      time = this.dayjs(time).format('YYYY-MM-DD')
      return time
    }
  }
}
</script>

<style lang="less" scoped>
.detail-page{
    margin: 0;
    padding: 0px;
    .header{
        border-bottom: 1px solid #efefef;
    .iconbtn_nav_back{
    font-size: 44px;
}
}
.type-area{
    padding: 15px;
}
}
.item{
    height: 75px;
    width: 100vw;
    display: flex;
    justify-content: space-between;
    .content{
        width: 100vw;
        padding: 15px;
        .title{
            font-weight: 500;
            margin-bottom: 10px;
        }
        .info{
            font-size: 12px;
            display: flex;
            justify-content: space-between;
            color: #b4b4bc;
            .time{
                flex: 1;
            }
            .see{
                width: 50px;
                margin-right: 20px;
            .eye{
                margin-right: 10px;
            }
            }
            .zan{
                width: 50px;
                .eye{
                margin-right: 10px;
            }
            }
        }
    }
}
</style>
